<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>Login - KitAdminCore</title>
    <script>
        if (window != window.top) top.location.href = self.location.href;
    </script>


    <link rel="stylesheet" href="${request.contextPath}/statics/libs/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="${request.contextPath}/statics/plugins/font-awesome/css/font-awesome.min.css" media="all" />
    <link rel="stylesheet" href="${request.contextPath}/statics/plugins/kit-admin/css/app.css" media="all" />
    <link rel="stylesheet" href="${request.contextPath}/statics/plugins/kit-admin/css/themes/default.css" media="all" id="skin" kit-skin />

    <link href="${request.contextPath}/statics/plugins/kit-admin/css/login.css" rel="stylesheet" />
    <link href="${request.contextPath}/statics/plugins/sideshow/css/normalize.css" rel="stylesheet" />
    <link href="${request.contextPath}/statics/plugins/sideshow/css/demo.css" rel="stylesheet" />
    <link href="${request.contextPath}/statics/plugins/sideshow/css/component.css" rel="stylesheet" />
    <!--[if IE]>
        <script src="./plugins/sideshow/js/html5.js"></script>
    <![endif]-->
    <style>
        canvas {
            position: absolute;
            z-index: -1;
        }
        
        .kit-login-box header h1 {
            line-height: normal;
        }
        
        .kit-login-box header {
            height: auto;
        }
        
        .content {
            position: relative;
        }
        
        .codrops-demos {
            position: absolute;
            bottom: 0;
            left: 40%;
            z-index: 10;
        }
        
        .codrops-demos a {
            border: 2px solid rgba(242, 242, 242, 0.41);
            color: rgba(255, 255, 255, 0.51);
        }
        
        .kit-pull-right button,
        .kit-login-main .layui-form-item input {
            background-color: transparent;
            color: white;
        }
        
        .kit-login-main .layui-form-item input::-webkit-input-placeholder {
            color: white;
        }
        
        .kit-login-main .layui-form-item input:-moz-placeholder {
            color: white;
        }
        
        .kit-login-main .layui-form-item input::-moz-placeholder {
            color: white;
        }
        
        .kit-login-main .layui-form-item input:-ms-input-placeholder {
            color: white;
        }
        
        .kit-pull-right button:hover {
            border-color: #009688;
            color: #009688
        }
    </style>
</head>


<body class="kit-login-bg">
    <div class="container demo-1">
        <div class="content">
            <div id="large-header" class="large-header">
                <canvas id="demo-canvas"></canvas>
                <div class="kit-login-box">
                    <header>
                        <h1>JeeBlade Login</h1>
                    </header>
                    <div class="kit-login-main">
                        <form id="loginForm" class="layui-form" lay-filter="form1">
                            <div class="layui-form-item">
                                <label class="kit-login-icon">
                                    <i class="layui-icon">&#xe612;</i>
                                </label>
                                <input type="text" name="userName" lay-verify="required" autocomplete="off" placeholder="这里输入用户名." class="layui-input" v-model="username">
                            </div>

                            <div class="layui-form-item">
                                <label class="kit-login-icon">
                                    <i class="layui-icon">&#xe642;</i>
                                </label>
                                <input type="password" name="password" lay-verify="required" autocomplete="off" placeholder="这里输入密码." class="layui-input" v-model="password" >
                            </div>
                            <!--<div class="layui-form-item">-->
                                <!--<label class="kit-login-icon">-->
                                    <!--<i class="layui-icon">&#xe642;</i>-->
                                <!--</label>-->
                                <!--<input type="number" name="validCode" lay-verify="required" autocomplete="off" placeholder="输入验证码." class="layui-input" v-model="captcha" @keyup.enter="login" >-->
                                <!--<span class="form-code" id="changeCode" style="position:absolute;right:2px; top:2px;">-->
                                    <!--<img alt="如果看不清楚，请单击图片刷新！" id="refImg" style="cursor:pointer;" :src="src" @click="refreshCode" title="点击刷新">-->
                                <!--</span>-->
                            <!--</div>-->
                            <div class="layui-form-item">
                                <div class="kit-pull-left kit-login-remember">
                                    <input type="checkbox" name="rememberMe" value="true" lay-skin="primary" checked title="记住帐号?">
                                </div>
                                <div style="text-align: center " class="kit-pull-right">
                                    <button class="layui-btn-lg layui-btn-primary" lay-submit lay-filter="form12"   style=" background-color:transparent"> <!--button的lay-filter要和监听事件的lay-filter一直才能监听-->
                                        <i class="fa fa-sign-in" aria-hidden="true"></i> &nbsp;&nbsp;登录
                                    </button>

                                    <!--<button class="layui-btn-lg layui-btn-primary" lay-submit lay-filter="login"  @click="login" style=" background-color:transparent">
                                        <i class="fa fa-sign-in" aria-hidden="true"></i> &nbsp;&nbsp;登录
                                    </button>-->
                                </div>
                                <div class="kit-clear"></div>
                            </div>
                        </form>
                    </div>
                    <footer>
                        <p>JEE BLADE © <a href="http://blog.fykj.cn" style="color:white; font-size:18px;" target="_blank">www.fykj.org</a></p>
                    </footer>
                </div>
            </div>
        </div>
    </div>
    <!-- /container -->
    <script type="text/javascript" src="${request.contextPath}/statics/libs/jquery.min.js"></script>
    <script type="text/javascript" src="${request.contextPath}/statics/libs/layui/layui.js"></script>
    <script type="text/javascript" src="${request.contextPath}/statics/libs/vue.min.js"></script>
    <script src="${request.contextPath}/statics/plugins/sideshow/js/TweenLite.min.js"></script>
    <script src="${request.contextPath}/statics/plugins/sideshow/js/EasePack.min.js"></script>
    <script src="${request.contextPath}/statics/plugins/sideshow/js/rAF.js"></script>
    <script src="${request.contextPath}/statics/plugins/sideshow/js/demo-1.js"></script>
    <script>

        layui.use(['layer', 'form'], function() {
            var form = layui.form;
            var vm = new Vue({
                el:'#loginForm',
                data:{
                    username: '',
                    password: '',
                    captcha: '',
                    error: false,
                    errorMsg: '',
                    src: 'captcha.jpg'
                },
                beforeCreate: function(){
                    if(self != top){
                        top.location.href = self.location.href;
                    }
                },
                methods: {
                    refreshCode: function(){
                        this.src = "captcha.jpg?t=" + $.now();
                    },
                    login: function (event) {
                        var data = "username="+vm.username+"&password="+vm.password+"&captcha="+vm.captcha;
                        debugger;
                        console.info("我进来啦")
                        $.ajax({
                            type: "POST",
                            url: "sys/login",
                            data: data,
                            dataType: "json",
                            success: function(result){
                                if(result.code == 0){//登录成功
                                    parent.location.href ='index.html';
                                }else{
                                    vm.error = true;
                                    vm.errorMsg = result.msg;

                                    vm.refreshCode();
                                }
                            }                        });
                    }
                }
            });


            form.on('submit(form12)', function(data){
                console.log(data.elem) //被执行事件的元素DOM对象，一般为button对象
                console.log(data.form) //被执行提交的form对象，一般在存在form标签时才会返回
                console.log(data.field) //当前容器的全部表单字段，名值对形式：{name: value}



                var data = "username="+vm.username+"&password="+vm.password+"&captcha="+vm.captcha;
                console.info("我进来啦")
                $.ajax({
                    type: "POST",
                    url: "sys/login",
                    data: data,
                    dataType: "json",
                    success: function(result){
                        if(result.code == 0){//登录成功
                            parent.location.href ='index.html';
                        }else{
                            vm.error = true;
                            vm.errorMsg = result.msg;

                            vm.refreshCode();
                        }
                    }                        });


                return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
            });




        })






        // layui.use(['layer', 'form'], function() {
        //     var layer = layui.layer,
        //         $ = layui.jquery,
        //         form = layui.form;
        //
        //     $('#changeCode').on('click', function() {
        //         $('#changeCode > img')[0].src = './build/images/GetVerfiyCode.png';
        //     });
        //
        //     //清理左侧菜单缓存
        //     var index = layer.load(2, {
        //         shade: [0.3, '#333']
        //     });
        //     $(window).on('load', function() {
        //         layer.close(index);
        //         form.on('submit(login)', function(data) {
        //             var loadIndex = layer.load(2, {
        //                 shade: [0.3, '#333']
        //             });
        //             location.href = '/';
        //             // $.post(data.form.action, data.field, function(res) {
        //             //     if (!res.rel) {
        //             //         layer.msg(res.msg, {
        //             //             icon: 2
        //             //         });
        //             //         loadIndex && layer.close(loadIndex);
        //             //         $('#changeCode').click(); //刷新验证码
        //             //     } else {
        //             //         setTimeout(function() {
        //             //             location.href = '/'
        //             //         }, 1500);
        //             //     }
        //             // }, 'json');
        //             return false;
        //         });
        //     }());
        //
        // });
    </script>
</body>

</html>